import {getCookie, getToken} from "../utils/cookie-utils.ts";
import {UserInfo} from "../types/commonTypes.ts";

export const useLoginToken = (): string => {
    const token = getToken()
    if (!token) {
        throw new Response("", {
            status: 503,
            statusText: "No Login",
        });
    }
    return token;
}
export const useLoginUser = (): UserInfo | null => {
    const userCk = getCookie('user')
    if (userCk) {
        return JSON.parse(userCk) as UserInfo
    }
    return null;
}